package router

import (
    "github.com/gogf/gf/frame/g"
    "github.com/gogf/gf/net/ghttp"
    "webserver/app/api"
    "webserver/app/middleware"
)

func init() {
	s := g.Server()
	s.Group("/", func(group *ghttp.RouterGroup) {
		group.ALL("/hello", api.Hello)
        group.ALL("/ping", api.Hello)
	})

    adminGroup := s.Group("/admins")
    configureAdminRoutes(adminGroup)
}

func configureAdminRoutes(group *ghttp.RouterGroup) {
    group.Middleware(
        middleware.CORS,
        middleware.ErrorHandler,
    )

    group.ALL("/ajax", api.Ajax)
    group.ALL("/mail", api.Mail)
    group.ALL("/script", api.ScriptApi)
}
